import fetch from 'dva/fetch';
import {message} from 'antd';
const BASE_URL= 'http://127.0.0.1:7001';
export default function(url,options={}){
    options.credentials ='include';
    options.method = options.method||'GET';
    options.headers = options.headers||{};
    options.headers["Content-Type"] = "application/json";
    options.headers["Accept"] = "application/json";
    options.headers["authorization"] = localStorage.getItem('token')||'';
    return fetch(BASE_URL+url,options)
    .then(response=>response.json())
    .then(body=>{ //{code:0,data:xx}
      if(body.code == 0){
        return body.data;
      }else{
        message.error(body.error);
      }
    });
  }